<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var re = /^[0-9]+.?[0-9]*$/;
        function f() {
            var sex = document.getElementsByName('sex');
            var se = "";
            for (var i = 0; i < sex.length; i++) {
                if (sex[i].checked){
                    se = sex[i].value;
                    break;
                } else if (i==sex.length-1){
                    alert("没选择儿童性别！");
                    return;
                }
            }
            var f = parseInt(document.getElementById('fsg').value);
            var m = parseInt(document.getElementById('msg').value);
            if ((!re.test(f))||(!re.test(m))) {
                alert("输入父母身高不是数字！ ");
                return;
            }if (f<=55 || f>=250 || m<=55 || m>=250){
                alert("输入父母身高要都是55-250之间！");
                return;
            }
            if (se=="man"){
                document.getElementById('jg').innerHTML =parseInt(((f+m)/2)*1.08);
            }
            if (se=="woman"){
                document.getElementById('jg').innerHTML =parseInt((f*0.923+m)/2);
            }
        }
        function f1() {
            var sex = document.getElementsByName('sex');
            for (var i = 0; i < sex.length; i++) {
                sex[i].checked = "";

            }
            document.getElementById('fsg').value ="";
            document.getElementById('msg').value ="";
        }
    </script>
</head>
<body>
    <div style="border: 1px solid orange;width: 100%;background-color: beige">
        <div style="margin-left: 10px">
        <h5>儿童身高测试</h5>
            儿童性别:<input type="radio" name="sex" value="man">男
            <input type="radio" name="sex" value="woman">女<br><br>
            爸爸的身高:<input type="text" id="fsg">厘米<br><br>
            妈妈的身高:<input type="text" id="msg">厘米<br><br>
            <button onclick="f()">查看结果</button><button onclick="f1()">重新测试</button>
        </div>
        <strong style="margin-left: 5px">测试结果</strong>
        <div style="border: 1px dashed orange;width: 300px;background-color: white;height: 40px;margin-left: 10px;margin-bottom: 10px;margin-top: 10px">
            小孩子未来的身高是:<font id="jg" color="red">?</font>厘米
        </div>
    </div>
</body>
</html>